package tt.dz.egobus.servicemanager.vo;

import org.hibernate.validator.constraints.NotBlank;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import tt.dz.egobus.bean.comment.TagBack;

import java.io.Serializable;

/**
 * @author Anson
 * @date 17-8-14
 * @name 订单标签试图vo
 * @since 1.0.6
 */
public class OrderTagViewVo implements Serializable {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrderTagViewVo.class);

    private static final long serialVersionUID = 5745208705679119993L;

    public TagBack convert() {
        TagBack pojo = new TagBack();
        try {
            BeanUtils.copyProperties(this, pojo);
        } catch (BeansException e) {
            LOGGER.error("OrderTagViewVo -> TagBack bean拷贝异常, viewVo={}", this, e);
        }
        return pojo;
    }

    public OrderTagViewVo view(TagBack pojo) {
        try {
            BeanUtils.copyProperties(pojo, this);
        } catch (BeansException e) {
            LOGGER.error(" TagBack ->  OrderTagViewVo bean拷贝异常, viewVo={}", this, e);
        }
        return this;
    }

    /**
     * 标签的id
     **/
    private String id;

    /**
     * 便签的值
     **/
    @NotBlank(message = "标签的值不能为空")
    private String value;

    /**
     * 标签的星级
     **/
    private int starLevel;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getStarLevel() {
        return starLevel;
    }

    public void setStarLevel(int starLevel) {
        this.starLevel = starLevel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        OrderTagViewVo back = (OrderTagViewVo) o;

        if (starLevel != back.starLevel) return false;
        if (id != null ? !id.equals(back.id) : back.id != null) return false;
        return value != null ? value.equals(back.value) : back.value == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (value != null ? value.hashCode() : 0);
        result = 31 * result + starLevel;
        return result;
    }

    @Override
    public String toString() {
        return "TagBack{" +
                "id='" + id + '\'' +
                ", value='" + value + '\'' +
                ", starLevel=" + starLevel +
                '}';
    }


}
